<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>根据id查询物料组成设计单信息</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/bootstraptable/bootstrap-table.min.css" rel="stylesheet">
    <style>
        .text_no_border {
            border: none;
        }
    </style>
</head>
<body>
<h5 style="color: #3e79b6">您正在做的业务是：产品设计--产品物料组成设计--物料组成设计单查询</h5>
<div class="container">
    <form id="material_auditInfo_form" class="form-horizontal">
        <div class="form-group">
            <div class="col-md-4">
                <label class="control-label col-md-6">设计单编号：</label>
                <div class="col-md-6">
                    <input type="text" class="form-control text_no_border" readonly style="background-color: white"  id="designId">
                </div>
            </div>
            <div class="col-md-4">
                <label class="control-label col-md-6"> 其中审核状态：</label>
                <div class="col-md-6">
                    <input type="text" class="form-control text_no_border" readonly style="background-color: white"  id="checkTag">
                </div>
            </div>
            <div class="col-md-4" style="text-align: right">
                <button type="button" class="btn btn-default" onclick="history.back(-1);">返回</button>
            </div>

        </div>

        <div class="panel panel-default" style="margin-top: 5px;">
            <div class="page-heading">
                <h2 style="text-align: center; margin-top: 30px;">物料组成设计单</h2>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-4 control-label">产品名称：</label>
                        <div class="col-sm-8">
                            <input type="text" name="productName" id="productName"
                                   class="form-control text_no_border"
                                   style="background-color: white"
                                   readonly
                            >
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-4 control-label">产品编号：</label>
                        <div class="col-sm-8">
                            <input type="text" name="productId" id="productId"
                                   class="form-control text_no_border"
                                   style="background-color: white"
                                   readonly>
                        </div>
                    </div>
                    <!--物料明细表格-->
                    <table style="margin-top: 20px;" class="table table-bordered table-striped" data-toggle="table"
                           id="material_auditInfo_details_table">
                        <thead>
                        <tr>
                            <th data-field="detailsNumber">序号</th>
                            <th data-field="productName">物料名称</th>
                            <th data-field="productId">物料编号</th>
                            <th data-field="type" data-formatter="formatType">用途类型</th>
                            <th data-field="productDescribe">描述</th>
                            <th data-field="amount">数量</th>
                            <th data-field="amountUnit">单位</th>
                            <th data-field="costPrice">单价（元）</th>
                            <th data-field="subtotal">小计（元）</th>
                        </tr>
                        </thead>
                    </table>

                    <div class="form-group" style="margin-top: 20px;">
                        <div class="col-sm-8">
                            <label class="col-sm-3 control-label">物料总成本：</label>
                            <div class="col-sm-8">
                                <input type="text" name="costPriceSum" id="costPriceSum"
                                       class="form-control text_no_border"
                                       style="background-color: white"
                                       readonly
                                >
                            </div>
                        </div>
                    </div>
                        <div class="form-group" style="margin-top: 15px;">
                            <div class="col-sm-6">
                                <label class="col-sm-4 control-label">设计人：</label>
                                <div class="col-sm-8">
                                    <input type="text" name="designer" id="designer"
                                           class="form-control text_no_border"
                                           style="background-color: white"
                                           readonly
                                    >
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <label class="col-sm-4 control-label">审核人：</label>
                                <div class="col-sm-8">
                                    <input type="text" name="checker" id="checker"
                                           class="form-control text_no_border"
                                           style="background-color: white"
                                           readonly
                                    >
                                </div>
                            </div>
                        </div>
                    <div class="form-group">
                        <div class="col-sm-6">
                            <label class="col-sm-4 control-label">审核时间：</label>
                            <div class="col-sm-8">
                                <input type="text" name="checkTime" id="checkTime"
                                       class="form-control text_no_border"
                                       style="background-color: white"
                                       readonly
                                >
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <label class="col-sm-4 control-label">登记时间：</label>
                            <div class="col-sm-8">
                                <input type="text" name="registerTime" id="registerTime"
                                       class="form-control text_no_border"
                                       style="background-color: white"
                                       readonly
                                >
                            </div>
                        </div>
                    </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <label class="col-sm-2 control-label">设计要求：</label>
                                <div class="col-sm-8">
                            <textarea rows="3" cols="100" class="form-control"
                                      style=" background-color: white;resize: none;border: none" name="moduleDescribe"
                                      id="moduleDescribe" readonly></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
    </form>
</div>

<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="/js/hAdmin.js?v=4.1.0"></script>
<!--<script type="text/javascript" src="/js/index.js"></script>-->

<!-- 第三方插件 -->
<script src="/js/plugins/pace/pace.min.js"></script>

<!--BootstrapTable-->
<script src="/bootstraptable/bootstrap-table.min.js"></script>
<script src="/bootstraptable/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="/js/currentTime.js"></script>

<script>
    //获取物料设计单id
    let id = localStorage.getItem("id")
    //物料设计单数据
    $.post("/design/module/getAuditById", {"id": id}, function (res) {
        console.log(res)
        if (res.checkTag == "S001-0") {
            $("#material_auditInfo_form #checkTag").val("等待").css("color", "#eea236")
            $("#material_auditInfo_form #designId").val(res.designId).css("color", "#eea236")
        } else if (res.checkTag == "S001-1") {
            $("#material_auditInfo_form #checkTag").val("通过").css("color", "green")
            $("#material_auditInfo_form #designId").val(res.designId).css("color", "green")
        } else {
            $("#material_auditInfo_form #checkTag").val("未通过").css("color", "red")
            $("#material_auditInfo_form #designId").val(res.designId).css("color", "red")
        }
        $("#material_auditInfo_form #designer").val(res.designer)
        $("#material_auditInfo_form #productName").val(res.productName)
        $("#material_auditInfo_form #productId").val(res.productId)
        $("#material_auditInfo_form #costPriceSum").val(res.costPriceSum)
        $("#material_auditInfo_form #moduleDescribe").val(res.moduleDescribe)
        $("#material_auditInfo_form #checker").val(res.checker)
        $("#material_auditInfo_form #registerTime").val(formater(res.registerTime))
        if(res.checkTime==null){
            $("#material_auditInfo_form #checkTime").val("")
        }else {
            $("#material_auditInfo_form #checkTime").val(formater(res.checkTime))
        }
    })
    //物料设计单明细数据
    $.post("/design/module/getMaterialDetailsById", {"id": id}, function (res) {
        for (let i = 0; i < res.length; i++) {
            $("#material_auditInfo_form #material_auditInfo_details_table").bootstrapTable("append", res[i])
        }
    })

    // 格式化"用途类型"单元格
    function formatType(value, row, index) {
        return row.type == 'Y001-1' ? '商品' : '物料'
    }
</script>
</body>
</html>